package cn.tedu.tmall.admin.mall.dao.repository.impl;

import cn.tedu.tmall.admin.mall.dao.mapper.GoodsMapper;
import cn.tedu.tmall.admin.mall.dao.repository.IGoodsRepository;
import cn.tedu.tmall.admin.mall.pojo.po.GoodsPO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class GoodsRepository implements IGoodsRepository {

    @Autowired
    private GoodsMapper goodsMapper;

    @Override
    public Integer selectTitle(String title) {
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("title",title);
        return goodsMapper.selectCount(queryWrapper);
    }
    @Override
    public Integer save(GoodsPO goodsPO) {
        return goodsMapper.insert(goodsPO);
    }

    @Override
    public List<GoodsPO> selectAll(QueryWrapper queryWrapper, Integer pageCount, Integer pageSize) {
        PageHelper.startPage(pageCount,pageSize);
        List list=goodsMapper.selectList(queryWrapper);
        return list;
    }

    @Override
    public GoodsPO selectById(Long id) {
        return goodsMapper.selectById(id);
    }

}
